package com.wonders.myfilter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

//@WebFilter(filterName = "HelloFilter", value = "/*") // 拦截所有请求
//@WebFilter(servletNames={"param-servlet"}) // 拦截发送给名称为param-servlet这个servlet的请求
@WebFilter(value = "/*", dispatcherTypes = {DispatcherType.FORWARD}) // 拦截forward类型的请求
public class HelloFilter implements Filter {
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        System.out.println("before");
        chain.doFilter(req, resp);
        System.out.println("after");
    }
}
